package com.bytefy.server;

import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.ServletHolder;

import com.bytefy.server.db.Persistence;
import com.bytefy.server.sandbox.UserDB;

public class Server extends Thread {
	private org.mortbay.jetty.Server server;
	private UserDB db = new UserDB("__global");

	public void run() {
		try {
			server = new org.mortbay.jetty.Server(8080);
			Context root = new Context(server, "/", Context.SESSIONS);
			root.addServlet(new ServletHolder(new JavascriptServlet()), "/*");
			server.start();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public static void main (String[] args) {
		Server s = new Server();
		s.start();
	}

	private void close() {
		new Persistence().close();
	}
	
}
